package com.zkingsoft.actions.admin;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.constance.Dictionary;
import com.zkingsoft.model.Users;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.UsersService;

/**
 * @description 用户管理
 * @author 姜友瑶
 * @email 935090232@qq.com
 * @date 2016-06-26
 */
@Controller
@RequestMapping(value = "admin/customer")
public class CustomerAdminController extends BaseController {

	@Resource
	private UsersService currentService;


	/**
	 * 
	 * @Description: 查询用户
	 * @author:姜友瑶
	 * @param request
	 * @param user
	 * @param pageVo
	 * @return 返回类型 AjaxResult
	 * @date 2016年8月31日
	 */
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(HttpServletRequest request, Users user, PaginationVO pageVo) {
		user.setIsDeleted(Dictionary.DELETED_N);
		user.setUserType(Dictionary.USER_TYPE_CUSTIMER);
		return showList(currentService, user, pageVo);
	}


	
	

	/**
	 * 
	 * @Description: 删除管理员
	 * @author:姜友瑶
	 * @param keys
	 * @return 返回类型 AjaxResult
	 * @date 2016年8月31日
	 */
	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}
	
	/**
	 * 
	 * @Description: 修改会员信息
	 * @author:姜友瑶
	 * @param keys
	 * @return 返回类型 AjaxResult
	 * @date 2016年8月31日
	 */
	@RequestMapping(value = "/chengUserStatu")
	public @ResponseBody AjaxResult chengUserStatu(Long id,int kind) {
		Users user=	currentService.findById(id);
		if(kind==1){
			user.setAccountStatus(Dictionary.ACCOUNT_STATUS_LOCKED);
		}else{
			user.setAccountStatus(Dictionary.ACCOUNT_STATUS_ACTIVATE);
		}
		return modify(currentService, user,"会员信息修改成功");
	}


}